from manim import *

class TriangleTypes(Scene):
    def construct(self):
        # 锐角三角形（不等边）
        acute_triangle = Polygon([0, 0, 0], [6, 0, 0], [2, 4, 0], color=PURPLE).scale(0.75).move_to(ORIGIN)
        acute_label = Text("锐角三角形: 三个角都是锐角", font_size=24).next_to(acute_triangle, DOWN)

        # 直角三角形
        right_triangle = Polygon([0, 0, 0], [6, 0, 0], [0, 6, 0], color=ORANGE).scale(0.75).move_to(ORIGIN)
        right_label = Text("直角三角形: 有切仅有一个角是直角", font_size=24).next_to(right_triangle, DOWN)

        # 钝角三角形
        obtuse_triangle = Polygon([0, 0, 0], [6, 0, 0], [1.5, 2.25, 0], color=YELLOW).scale(0.75).move_to(ORIGIN)
        obtuse_label = Text("钝角三角形: 有切仅有一个角是钝角", font_size=24).next_to(obtuse_triangle, DOWN)

        # 不等边三角形
        scalene_triangle = Polygon([0, 0, 0], [6, 0, 0], [4, 5, 0], color=BLUE).scale(0.75).move_to(ORIGIN)
        scalene_label = Text("不等边三角形: 三条边长度都不相等", font_size=24).next_to(scalene_triangle, DOWN)

        # 等腰三角形
        isosceles_triangle = Polygon([0, 0, 0], [6, 0, 0], [3, 6, 0], color=GREEN).scale(0.75).move_to(ORIGIN)
        isosceles_label = Text("等腰三角形: 有两条边长度相等", font_size=24).next_to(isosceles_triangle, DOWN)

        # 等边三角形
        equilateral_triangle = Polygon([0, 0, 0], [6, 0, 0], [3, 5.196, 0], color=RED).scale(0.75).move_to(ORIGIN)
        equilateral_label = Text("等边三角形: 三条边长度都相等", font_size=24).next_to(equilateral_triangle, DOWN)

        # 创建一个列表来存储所有的三角形和标签
        triangles = [
            (acute_triangle, acute_label),
            (right_triangle, right_label),
            (obtuse_triangle, obtuse_label),
            (scalene_triangle, scalene_label),
            (isosceles_triangle, isosceles_label),
            (equilateral_triangle, equilateral_label)
        ]

        for triangle, label in triangles:
            self.play(Create(triangle))
            self.play(Write(label))
            self.wait(2)
            self.play(FadeOut(triangle), FadeOut(label))

if __name__ == "__main__":
    scene = TriangleTypes()
    scene.render()